package 力扣日常刷题.木22一月.第16天0128;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 帅小伙
 * @date 2022/1/28
 * @description
 */
public class Demo24字符串中等单词频率 {


    class WordsFrequency {
        Map<String,Integer> frequency ;
        public WordsFrequency(String[] book) {
            frequency = new HashMap<>();
            for (String s : book) {
                frequency.put(s,frequency.getOrDefault(s,0)+1);
            }
        }

        public int get(String word) {
            return frequency.getOrDefault(word,0);
        }
    }
}
